package com.hr.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hr.entity.AoaAttachmentList;
import com.hr.service.AoaAttachmentListService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * (AoaAttachmentList)表控制层
 *
 * @author makejava
 * @since 2022-06-16 09:58:53
 */
@RestController
@RequestMapping("aoaAttachmentList")
public class AoaAttachmentListController{
    /**
     * 服务对象
     */
    @Resource
    private AoaAttachmentListService aoaAttachmentListService;

    /**
     * 查所有考勤数据
     */
    @GetMapping("/queryList")
    public Page<AoaAttachmentList> queryList(Page<AoaAttachmentList> page,String userName){

            page=aoaAttachmentListService.queryList(page,userName);

        return page;
    }

    /**
     * 考勤修改数据
     * T:类型
     * Z:状态
     * B:备注
     * @return
     */
    @PostMapping("/updateTZB")
    public ResponseEntity<String> updateTZB(@RequestBody AoaAttachmentList a){
        int i=aoaAttachmentListService.updateTZB(a);
        return ResponseEntity.ok(i>0?"修改成功":"修改失败");
    }

    /**
     * 根据Id删除考勤数据
     * @param attachmentId
     * @return
     */
    @GetMapping("/deleteById")
    public ResponseEntity<String> deleteById(Long attachmentId){
        int b=aoaAttachmentListService.deleteById(attachmentId);
        return ResponseEntity.ok(b>0?"删除成功":"删除失败");
    }

    /**
     * 查询一周考勤报表
     * @return
     */
    @GetMapping("/queryYiZhou")
    public List<AoaAttachmentList> queryYiZhou(String startSJ,String endSJ){
        List<AoaAttachmentList> list=aoaAttachmentListService.queryYiZhou(startSJ,endSJ);
        return list;
    }
    /**
     * 查询月考勤报表
     * 部门模糊查询
     * @return
     */
    @GetMapping("/queryMonth")
    public List<AoaAttachmentList> queryMonth(String startSJ,String deptS){
        List<AoaAttachmentList> list=null;
        if(deptS!=null || deptS!=""){
             list=aoaAttachmentListService.queryMonth(startSJ,deptS);
        }else {
            list = aoaAttachmentListService.queryMonth(startSJ);
        }
        return list;
    }

    /**
     * 部门模糊查询
     */
    @GetMapping("/selectDept")
    public List<AoaAttachmentList> selectDept(String startSJ,String endSJ,String deptS){
        List<AoaAttachmentList> list=aoaAttachmentListService.selectDept(startSJ,endSJ,deptS);
        return list;
    }

}

